import 'package:FlutterRoute/common/models/Store.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../common/models/LoginUser.dart';

class ProviderVC extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    return Scaffold(
      appBar: AppBar(title: Text("Provider"),),
      body: Center(
        child: Column(
          children: [
            Builder(builder: (context){
              return Text("登录状态:${Store.of<LoginUserProvider>(context).curUser.isLogin}");
            }),
            Text("用户名:${Store.of<LoginUserProvider>(context).curUser.name}"),
            FlatButton(onPressed: ()=> Store.of<LoginUserProvider>(context,listen: false).login(), child: Text("Login")),
            // Builder(builder: (context){
            //   debugPrint("===== Login Button 刷新了");
            //   return FlatButton(onPressed: ()=> context.read<LoginUserProvider>().login(), child: Text("Login"));
            // })
          ],
        ),
      )
    );
  }
}

//Provider.of<LoginUserProvider>(context,listen: false).login()